import _http from '@/common/http.js'
import config from '@/common/api.js'
const baseURL = config.serverURL

// 首页通知列表
export const getNotice = async (pageNo = 1) => {
  const url = `${baseURL}/market/select/srvmarket_announcement_select`
  const req = {
    "serviceName": "srvmarket_announcement_select",
    "colNames": ["*"],
    "page": {
      "pageNo": pageNo,
      "rownumber": 5
    },
    "order": [{
      "colName": "is_top",
      "orderType": "desc"
    }]
  }
  const res = await _http.post(url, req)
  if (res.data.state === 'SUCCESS') {
    return res.data
  }
}

// 查找轮播图
export const getSwiper = async (pageNo = 1) => {
  const url = `${baseURL}/market/select/srvmarket_carousel_picture_select`
  const req = {
    "serviceName": "srvmarket_carousel_picture_select",
    "colNames": ["*"],
    "page": {
      "pageNo": pageNo,
      "rownumber": 5
    },
    "order": [{
      "colName": "seq",
      "orderType": "desc"
    }]
  }
  const res = await _http.post(url, req)
  if (res.data.state === 'SUCCESS') {
    return res.data
  }
}

// 获取菜单及其通知数量
export const getMenu = async (pageNo = 1) => {
  const url = `${baseURL}/market/select/srvmarket_user_menu_numtip_select`
  const req = {
    "serviceName": "srvmarket_user_menu_numtip_select",
    "colNames": ["*"],
    // "page": {
    //   "pageNo": pageNo,
    //   "rownumber": 10
    // },
    condition: [
      // {
      //   colName: "client_type",
      //   ruleType: "like",
      //   value: "APP"
      // },
      // {
      //   colName: "menu_no",
      //   ruleType: "in",
      //   value: "project_create,bidding_mgt,market_capital_audit_mgt,pre_assessment_mgt,pre_assessment_mgt,pre_assessment_mgt"
      // }
    ],
    // order: [{
    //   colName: "seq",
    //   orderType: "asc"
    // }]
  }
  const res = await _http.post(url, req)
  if (res.data.state === 'SUCCESS') {
    console.log(res.data)
    return res.data
  }
}
